package com.ruoyi.information.service.pc.impl;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.PageUtils;
import com.ruoyi.information.domain.pc.BoCollectionSpaceRes;
import com.ruoyi.information.domain.pc.ParkS;
import com.ruoyi.information.service.pc.IUserReserveParkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.information.mapper.pc.UserReserveParkMapper;
import com.ruoyi.information.domain.pc.UserReservePark;

/**
 * 预选产品Service业务层处理
 *
 * @author ruoyi
 * @date 2023-05-19
 */
@Service
public class UserReserveParkServiceImpl implements IUserReserveParkService
{
    @Autowired
    private UserReserveParkMapper userReserveParkMapper;

    /**
     * 查询预选产品
     *
     * @param id 预选产品主键
     * @return 预选产品
     */
    @Override
    public UserReservePark selectUserReserveParkById(Long id)
    {
        return userReserveParkMapper.selectUserReserveParkById(id);
    }

    /**
     * 查询预选产品列表
     *
     * @param userReservePark 预选产品
     * @return 预选产品
     */
    @Override
    public List<BoCollectionSpaceRes> selectUserReserveParkList(UserReservePark userReservePark)
    {
        List<ParkS> reserveParks = userReserveParkMapper.selectUserReserveParkList(userReservePark);
        List<BoCollectionSpaceRes> spaceRes = new ArrayList<>();
        if (!reserveParks.isEmpty()) {
            PageUtils.startPage();
            spaceRes = userReserveParkMapper.collectionSpace(reserveParks, 1);
        }
        return spaceRes;
    }

    /**
     * 新增预选产品
     *
     * @param userReservePark 预选产品
     * @return 结果
     */
    @Override
    public int insertUserReservePark(UserReservePark userReservePark)
    {
        userReservePark.setCreateTime(DateUtils.getNowDate());
        return userReserveParkMapper.insertUserReservePark(userReservePark);
    }

    /**
     * 修改预选产品
     *
     * @param userReservePark 预选产品
     * @return 结果
     */
    @Override
    public int updateUserReservePark(UserReservePark userReservePark)
    {
        userReservePark.setUpdateTime(DateUtils.getNowDate());
        return userReserveParkMapper.updateUserReservePark(userReservePark);
    }

    /**
     * 批量删除预选产品
     *
     * @param ids 需要删除的预选产品主键
     * @return 结果
     */
    @Override
    public int deleteUserReserveParkByIds(Long[] ids)
    {
        return userReserveParkMapper.deleteUserReserveParkByIds(ids);
    }

    /**
     * 删除预选产品信息
     *
     * @param id 预选产品主键
     * @return 结果
     */
    @Override
    public int deleteUserReserveParkById(Long id)
    {
        return userReserveParkMapper.deleteUserReserveParkById(id);
    }
}
